package com.oneonefive.trainticketsystem.config;

import com.oneonefive.trainticketsystem.interceptor.AccessInterceptor;
import com.oneonefive.trainticketsystem.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration("mvcConfig1")
public class MvcConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new AccessInterceptor()).order(0)
                .addPathPatterns("/**");
        registry.addInterceptor(new LoginInterceptor()).order(1)
                .excludePathPatterns(
                        "/loginCheck", "/checkUser"
                );
    }
}
